import React, { Component, Suspense, lazy } from 'react'

import { Route, Switch, Redirect } from 'react-router-dom'

const Login = lazy(() => import('./pages/Login'))
const News = lazy(() => import('./pages/News'))
const Me = lazy(() => import('./pages/Me'))

import checkLogin from './hoc/checkLogin'

class App2 extends Component {
  render() {
    return (
      <>
        <Suspense fallback="加载中...">
          <Switch>
            <Route path="/login" component={Login} />
            <Route path="/news" component={News} />
            <Route path="/me" component={checkLogin(Me)} />
            <Redirect exact from="/" to="/news" />
          </Switch>
        </Suspense>
      </>
    );

  }
}

export default App2;
